from django.contrib.auth.models import User

from users.models import UserInfo


def get_manual_authentication(user):
    if isinstance(user, UserInfo):
        return user.is_manual_authenticated

    if isinstance(user, User):
        user_info = UserInfo.objects.get(user_ptr_id=user.id)
        return user_info.is_manual_authenticated

    # 防御性
    raise Exception()
